package constant.milk.cashbook.database;

import android.content.Context;

public class DbDeleteQuery
{
	private Context context;
	private DbAdapter db;
	
	public DbDeleteQuery(Context context, DbAdapter db)
	{
		this.context = context;
		this.db = db;
	}
	
	public void setBeginTansaction() throws Exception
	{
		db.beginTansaction(context);
	}
	
	public void setSuccessful() throws Exception
	{
		db.setTransactionSuccessful();
	}
	
	public void setEndTansaction() throws Exception
	{
		db.endTransaction(context);
	}
	
	/**
	 * 현금 테이블에 데이터를 삭제한다.
	 * @param id
	 */
	public void setRealMoneyDelete(String id) throws Exception
	{
		String [] whereArgs = new String[]{id};
		
		db.delete(context, TableName.REAL_MONEY, "id = ?", whereArgs);
	}
	
	/**
	 * 통장 테이블에 데이터를 삭제한다.
	 * @param id
	 */
	public void setBankBookDelete(String id) throws Exception
	{
		String [] whereArgs = new String[]{id};
		
		db.delete(context, TableName.BANK_BOOK, "id = ?", whereArgs);
	}
	
	/**
	 * 체크카드 테이블에 데이터를 삭제한다.
	 * @param id
	 */
	public void setCheckCardDelete(String id) throws Exception
	{
		String [] whereArgs = new String[]{id};
		
		db.delete(context, TableName.CHECK_CARD, "id = ?", whereArgs);
	}
	
	/**
	 * 신용카드 테이블에 데이터를 삭제한다.
	 * @param id
	 */
	public void setCreditCardDelete(String id) throws Exception
	{
		String [] whereArgs = new String[]{id};
		
		db.delete(context, TableName.CREDIT_CARD, "id = ?", whereArgs);
	}
	
	/**
	 * 핸드폰 테이블에 데이터를 삭제한다.
	 * @param id
	 */
	public void setPhoneDelete(String id) throws Exception
	{
		String [] whereArgs = new String[]{id};
		
		db.delete(context, TableName.PHONE, "id = ?", whereArgs);
	}
	
	/**
	 * 상품권 테이블에 데이터를 삭제한다.
	 * @param id
	 */
	public void setGiftCardDelete(String id) throws Exception
	{
		String [] whereArgs = new String[]{id};
		
		db.delete(context, TableName.GIFT_CARD, "id = ?", whereArgs);
	}
	
	public void setInOutDelete(String id) throws Exception
	{
		String [] whereArgs = new String[]{id};
		
		db.delete(context, TableName.IN_OUT, "id = ?", whereArgs);
	}
	
	public void setInOutDeleteLinkId(String id) throws Exception
	{
		String [] whereArgs = new String[]{id};
		
		db.delete(context, TableName.IN_OUT, "linkid = ?", whereArgs);
	}
	
	public void setCategoryMainDelete(String id) throws Exception
	{
		String [] whereArgs = new String[]{id};
		
		db.delete(context, TableName.CATEGORY_MAIN, "id = ?", whereArgs);
	}
	
	public void setCategorySubDeleteLinkId(String id) throws Exception
	{
		String [] whereArgs = new String[]{id};
		
		db.delete(context, TableName.CATEGORY_SUB, "linkid = ?", whereArgs);
	}
	
	public void setCategorySubDelete(String id) throws Exception
	{
		String [] whereArgs = new String[]{id};
		
		db.delete(context, TableName.CATEGORY_SUB, "id = ?", whereArgs);
	}
	
	public void setAutoMainDelete(String id) throws Exception
	{
		String [] whereArgs = new String[]{id};
		
		db.delete(context, TableName.AUTO_MAIN, "id = ?", whereArgs);
	}
	
	public void setSmsDelete(String id) throws Exception
	{
		String [] whereArgs = new String[]{id};
		
		db.delete(context, TableName.SMS, "id = ?", whereArgs);
	}
	
	public void setHalbuDelete(String id) throws Exception
	{
		String [] whereArgs = new String[]{id};
		
		db.delete(context, TableName.HALBU, "id = ?", whereArgs);
	}
	
	public void setBudgetDelete(String id) throws Exception
	{
		String [] whereArgs = new String[]{id};
		
		db.delete(context, TableName.BUDGET, "id = ?", whereArgs);
	}
	
	public void setMainSettingDelete(String id) throws Exception
	{
		String [] whereArgs = new String[]{id};
		
		db.delete(context, TableName.MAIN_SETTING, "id = ?", whereArgs);
	}
	
	public void setWidgetSettingDelete(String id) throws Exception
	{
		String [] whereArgs = new String[]{id};
		
		db.delete(context, TableName.WIDGET_SETTING, "id = ?", whereArgs);
	}
}
